home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / kpty.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-10-10  |  3.5 KB  |  150 lines

  1. /* This file is part of the KDE libraries
  2.  
  3.     Copyright (C) 1997-2002 The Konsole Developers
  4.     Copyright (C) 2002 Waldo Bastian <bastian@kde.org>
  5.     Copyright (C) 2002-2003 Oswald Buddenhagen <ossi@kde.org>
  6.  
  7.     This library is free software; you can redistribute it and/or
  8.     modify it under the terms of the GNU Library General Public
  9.     License as published by the Free Software Foundation; either
  10.     version 2 of the License, or (at your option) any later version.
  11.  
  12.     This library is distributed in the hope that it will be useful,
  13.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  15.     Library General Public License for more details.
  16.  
  17.     You should have received a copy of the GNU Library General Public License
  18.     along with this library; see the file COPYING.LIB.  If not, write to
  19.     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  20.     Boston, MA 02110-1301, USA.
  21. */
  22.  
  23. #ifndef __kpty_h__
  24. #define __kpty_h__
  25.  
  26. #include <qglobal.h>
  27. #include <kdelibs_export.h>
  28.  
  29. #ifdef Q_OS_UNIX
  30.  
  31. struct KPtyPrivate;
  32.  
  33. /**
  34.  * Provides a high level representation of a pseudo tty pair, including
  35.  * utmp support.
  36.  * ...
  37.  *
  38.  * @since 3.2
  39.  **/
  40. class KDECORE_EXPORT KPty {
  41.  
  42. public:
  43.  
  44.   /**
  45.    * Constructor
  46.    */
  47.   KPty();
  48.  
  49.   /**
  50.    * Destructor:
  51.    *
  52.    *  If the pty is still open, it will be closed. Note, however, that
  53.    *  an utmp registration is @em not undone.
  54.   */
  55.   ~KPty();
  56.  
  57.   /**
  58.    * Create a pty master/slave pair.
  59.    *
  60.    * @return true if a pty pair was successfully opened
  61.    */
  62.   bool open();
  63.  
  64.   /**
  65.    * Close the pty master/slave pair.
  66.    */
  67.   void close();
  68.  
  69.   /**
  70.    * Creates a new session and process group and makes this pty the
  71.    * controlling tty.
  72.    */
  73.   void setCTty();
  74.  
  75.   /**
  76.    * Creates an utmp entry for the tty.
  77.    * This function must be called after calling setCTty and
  78.    * making this pty the stdin.
  79.    * @param user the user to be logged on
  80.    * @param remotehost the host from which the login is coming. This is
  81.    *  @em not the local host. For remote logins it should be the hostname
  82.    *  of the client. For local logins from inside an X session it should
  83.    *  be the name of the X display. Otherwise it should be empty.
  84.    */
  85.   void login(const char *user = 0, const char *remotehost = 0);
  86.  
  87.   /**
  88.    * Removes the utmp entry for this tty.
  89.    */
  90.   void logout();
  91.  
  92.   /**
  93.    * Change the logical (screen) size of the pty.
  94.    * The default is 24 lines by 80 columns.
  95.    *
  96.    * @param lines the number of rows
  97.    * @param columns the number of columns
  98.    */
  99.   void setWinSize(int lines, int columns);
  100.  
  101.   /**
  102.    * Set whether the pty should honor Xon/Xoff flow control.
  103.    *
  104.    * Xon/Xoff flow control is off by default.
  105.    *
  106.    * @param useXonXoff true if Xon/Xoff flow control should be used.
  107.    */
  108.   void setXonXoff(bool useXonXoff);
  109.  
  110.   /**
  111.    * Set the pty in utf8 mode on systems that support it.
  112.    * 
  113.    * See the man page of "stty iutf8" for more info.
  114.    *
  115.    * @since 3.4
  116.    */
  117.   void setUtf8Mode(bool useUtf8);
  118.  
  119.  
  120.   /**
  121.    * @return the name of the slave pty device.
  122.    *
  123.    * This function should be called only while the pty is open.
  124.    */
  125.   const char *ttyName() const;
  126.  
  127.   /**
  128.    * @return the file descriptor of the master pty
  129.    *
  130.    * This function should be called only while the pty is open.
  131.    */
  132.   int masterFd() const;
  133.  
  134.   /**
  135.    * @return the file descriptor of the slave pty
  136.    *
  137.    * This function should be called only while the pty is open.
  138.    */
  139.   int slaveFd() const;
  140.  
  141. private:
  142.   bool chownpty(bool grant);
  143.  
  144.   KPtyPrivate *d;
  145. };
  146.  
  147. #endif //Q_OS_UNIX
  148. #endif
  149.  
  150.